package com.ruoyi.web.controller.regulatory;

import cn.hutool.core.util.URLUtil;
import com.alibaba.excel.EasyExcel;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.regulatory.domain.JySchoolClassHistory;
import com.ruoyi.regulatory.service.JySchoolClassHistoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 学校班级Controller
 *
 * @author ruoyi
 * @date 2024-05-25
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/regulatory/school_class_history")
public class JySchoolClassHistoryController extends BaseController {
    private final JySchoolClassHistoryService jySchoolClassHistoryService;

    /**
     * 查询学校班级列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public AjaxResult list(JySchoolClassHistory jySchoolClassHistory) {
        List<JySchoolClassHistory> list = jySchoolClassHistoryService.selectJySchoolClassHistoryList(jySchoolClassHistory);
        return success(list);
    }

    /**
     * 获取学校班级详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(jySchoolClassHistoryService.selectJySchoolClassHistoryById(id));
    }

    /**
     * 新增学校班级
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "学校班级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JySchoolClassHistory jySchoolClassHistory) {
        return toAjax(jySchoolClassHistoryService.insertJySchoolClassHistory(jySchoolClassHistory));
    }

    /**
     * 修改学校班级
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "学校班级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JySchoolClassHistory jySchoolClassHistory) {
        return toAjax(jySchoolClassHistoryService.updateJySchoolClassHistory(jySchoolClassHistory));
    }

    /**
     * 删除学校班级
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "学校班级", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(jySchoolClassHistoryService.deleteJySchoolClassHistoryByIds(ids));
    }
}
